package com.soulgame;

import java.util.Map;

import android.app.Activity;

import com.soul.sdk.SGProxy;
import com.soul.sdk.constants.Constants;
import com.soul.sdk.plugin.user.IExitListener;
import com.soul.sdk.plugin.user.UserPluginAdapter;
import com.soul.sdk.utils.Arrays;
import com.soul.sdk.utils.SGDebug;

/**
 * @author lch
 * @version Create time：2017-1-3
 * @类说明: 注意：插件类是{@link #UserProxy}在此类通过无参构造器 反射实例化的，构造器不能带参数 所写插件 需要配置，配置文件 在
 *       assets 下的 {@link Constants#PATH_SG_PLUGIN_CONFIG}
 */
public class BaiduUserPlugin extends UserPluginAdapter {

	private String[] supportedMethods = { "login", "switchLogin", "exit" };

	private Activity mActivity;

	public BaiduUserPlugin() {
		SGDebug.i(this, "BaiduUserPlugin()");
		this.mActivity = SGProxy.getInstance().getActivity();
		// 初始化百度SDK
		BaiduSdk.getInstance().init(mActivity, SGProxy.getInstance().getSDKParamsJSON(mActivity));
	}

	@Override
	public boolean isSupportMethod(String methodName) {
		return Arrays.contain(supportedMethods, methodName);
	}

	@Override
	public void login(Activity pActivity, Map<String, String> customParams) {
		BaiduSdk.getInstance().login(pActivity, customParams);
	}

	@Override
	public void switchLogin(Activity pActivity, Map<String, String> customParams) {
		BaiduSdk.getInstance().switchLogin(pActivity, customParams);
	}

	@Override
	public void exit(Activity pActivity, Map<String, String> customParams, IExitListener pExitListener) {
		BaiduSdk.getInstance().exit(pActivity, customParams, pExitListener);
	}

}
